<extend name="common/base"/>
<block name="header">
	        <link href="__STATIC__/zui/css/zui.min.css" rel="stylesheet">
        <!-- core - css -->
        <link href="__STATIC__/zui/themes/css/style.css" rel="stylesheet">
        <link href="__STATIC__/zui/themes/green/core.css" id="zui-link-theme" rel="stylesheet">
        <!-- plug - css -->
        <link href="__CSS__/style.css" rel="stylesheet"></head>

	<script type="text/javascript">
    var SITEURL = '__ROOT__/';
    var zhpConfig = {
        //基础配置
        baseUrl: '__ROOT__/',
        uploadUrl: "{:url('upload')}",
        deleteUrl: "{:url('delpic')}",
        //自定义配置
        libDir: '__STATIC__/zui/lib/',
        lang: "{:config('LANG_SET')}",
        Module:'{$module}',
        Controller:'{$controller}',
        Action:'{$action}',
    };
</script>
<!--[if lt IE 9]>
    <script type="text/javascript" src="__STATIC__/jquery/jquery-1.12.1.min.js"></script>
<![endif]-->
<!--[if gte IE 9]><!-->
<script type="text/javascript" src="__STATIC__/jquery/jquery-2.2.1.min.js"></script>
<!--<![endif]-->
<script src="__STATIC__/zui/lib/cookie/cookie.js" type="text/javascript"></script>
<script src="__STATIC__/zui/js/bootstrap.min.js" type="text/javascript"></script>
<script src="__STATIC__/zui/js/zui.lite.js" type="text/javascript"></script>
<script src="__STATIC__/zui/do.js" type="text/javascript"></script>
<script src="__STATIC__/zui/config.js" type="text/javascript"></script>
</block>
<block name="body">

<div class="col-sm-9">
	<form method="post" autocomplete="off" id="articleform" data-toggle="ajaxform" action="{:url('save')}" enctype="multipart/form-data">
	<div class="form-group">
	<div class="input-group">
	<zui:input type="text" name="title" value="{$article.title}" title="标题" />
	</div>
	</div>
	<div class="form-group">
	<div class="input-group">
	<zui:input type="text" name="shorttitle" value="{$article.shorttitle}" title="别名" />
	</div>
	</div>
	<if condition="(isset($article['aid']) && empty($article['aid'])) || (isset($article['catid']) && empty($article['catid']))">
	<div class="form-group">
	<div class="input-group">
		<zui:select options="categories" selected="{$catid}" tile="分类" />
	</div>
	</div>
	</if>
	<div class="form-group">
	<div class="input-group">
	<zui:input type="text" name="author" value="{$article.author}" title="作者" />
	</div>
	</div>
	<div class="form-group">
	<div class="input-group">
	<zui:input type="text" name="from" value="{$article.from}" title="来源" />
	<zui:input type="text" name="fromurl" value="{$article.fromurl}" title="地址" />
	</div>
	</div>
	<if condition="isset($article['aid']) && $article['aid']">
	<div class="form-group">
	<div class="input-group">
	<zui:select name="{:config('paginate.var_page')}" title="保存到" options="pages" selected="{$article_content.pageorder}" />
		<a href="index.php?group=user&option=article&task=addpage&aid=$aid" class="btn">添加一个新页面</a>
	<if condition="$article_content">
		<a href="index.php?group=user&option=article&task=delpage&aid=$aid&cid=$article_content[cid]" class="btn">删除当前页</a>
	</if>
	{$multi}
	</div></div>
	</if>
				<style>
				.xhe_vista table{
				border-collapse: separate;
				}
				</style>
	<div class="form-group">
				<textarea id="jycms-ttHtmlEditor" name="content" style="width: 860px; height: 500px;">{$article_content.content}</textarea>
</div>
	<div class="form-group">
	<div class="input-group">
	<zui:input type="text" name="tagname" value="{$tagname}" title="标签" note="请以半角逗号分隔" />
	</div>
	</div>

	<div class="form-group">
	<div class="input-group">
	<zui:input type="textarea" name="summary" value="{$article.summary}" title="摘要" />
	</div>
	</div>

<if condition="$article_content['pageorder']<2 && $customfields">
				<div class="text-left">自定义字段</div>
				<select id="customfieldid" name="customfieldid" onchange="showdivcustomfieldtext()">
					<option value="0" {if $article[customfieldid]==0}selected{/if}>不使用</option>
					{loop $customfields $v}
					<option value="{$v[customfieldid]}" {if $article[customfieldid]==$v[customfieldid]}selected{/if}>$v[name]</option>
					{/loop}
				</select>
				{$cfhtml}
</if>
				<div>
					<button type="button" id="issuance" class="btn" name="articlebutton" onclick="validatef(this);"><strong>提交</strong></button>
					<label><input type="checkbox" name="addpage" value="1" class="pc"> 保存后添加一个新页面</label>
					<!--{if $cate[allowcomment]}--><label for="ck_allowcomment"><input type="checkbox" name="forbidcomment" id="ck_allowcomment" class="pc" value="1"{if isset($article['allowcomment']) && empty($article['allowcomment'])}checked="checked"{/if} /> 禁止评论此文章</label><!--{/if}-->
				</div>
				<input type="hidden" id="aid" name="aid" value="$article[aid]" />
				<input type="hidden" name="cid" value="$article_content[cid]" />
				<input type="hidden" id="attach_ids" name="attach_ids" value="0" />
				<input type="hidden" name="articlesubmit" value="true" />
				<!--{if $op=='edit'||$op=='addpage'}-->
				<input type="hidden" name="catid" value="$catid" />
				<!--{/if}-->
				<input type="hidden" name="formhash" value="{FORMHASH}" />
				<input type="hidden" name="authcode" value="{$authcode}" />
			</form>
		</article>
</div>
<div class="col-sm-3">
	<div class="widget d_textbanner" style="padding: 1px 4px 4px 16px;">
		<p class="style02"><strong>上传附件</strong></p>
		<p>为当前文章上传图片、文件附件资源。<br>上传完毕后，需要插入到文章内容中才可以显示。</p>
		<script src="__STATIC__/jquery/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
		<link href="__STATIC__/jquery/uploadify/uploadify.css" rel="stylesheet" type="text/css">
		<script type="text/javascript">
		$(function() {
		    $('#uploadify').uploadify({
				'overrideEvents': ['onUploadStart'],
				'method'      : 'POST',
		    	buttonClass   : 'btn',
				fileObjName   : 'attach',
		        height        : 20,
		        width         : 80,
		        swf           : '__STATIC__/jquery/uploadify/uploadify.swf',
		        uploader      : '{CMS_URL}index.php?group=user&option=upload&aid={$aid}',
				formData      : {'authcode':'{$authcode}','formhash':'{FORMHASH}'},
		        fileSizeLimit : '100MB',
				queueID       : 'fileQueue',
				auto          : false,
				buttonText    : '浏览',
				CompleteText  : '已完成',
				CancelledText : '已取消',
		        multi         : true,
		        'onUploadSuccess' : function(file, data, response) {
		            //alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
					$('#' + file.id).find('.data').html(' - 已完成');
		            eval(data);
		        },
		        'onUploadError' : function(file, errorCode, errorMsg, errorString) {
					if(errorString!='Cancelled')
		            alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
		        },
		        'onUploadStart' : function(file) {
		        	$('#articleform').bind('submit', hasUpload);
		            $('#startUpload').hide();
					$('#cancelUpload').show();
		        },
		        'onQueueComplete' : function(queueData) {
		            $('#startUpload').hide();
					$('#cancelUpload').hide();
		        	$('#articleform').unbind('submit', hasUpload);
		        },
		        'onSelect' : function(file) {
		        	$('#articleform').bind('submit', hasUpload);
		            $('#startUpload').show();
		        },
		        'onCancel' : function(file) {
					if(this.queueData.queueLength==1) {
						$('#startUpload').hide();
		        		$('#articleform').unbind('submit', hasUpload);
					}
		        },
			});
		});
		function hasUpload(){
			return false;
		}
		</script>
		<div id="uploadbox">
			<div id="fileQueue"></div>
			<input type="file" name="uploadify" id="uploadify" />
			<button class="btn" onclick="$('#uploadify').uploadify('upload', '*')" id="startUpload" style="display: none;">上传</button>
			<button class="btn" onclick="$('#uploadify').uploadify('cancel', '*')" id="cancelUpload" style="display: none;">取消</button>
			<p class="textmsg" id="divshowuploadmsg" style="display:block"></p>
		</div>
		<iframe id="uploadframe" name="uploadframe" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank"></iframe>
		<div style="max-height: 620px; overflow: auto;" class="d_postlist">
			<ul id="attach_image_body">
				{$article.attach_image}
			</ul>
		</div>
		<div id="attach_file_body">{$article.attach_file}</div>

	</div>
</div>
</block>
<block name="script">
<script language="javascript" src="__STATIC__/xheditor-1.2.1/xheditor-1.2.1.min.js"></script>
<script language="javascript" src="__STATIC__/xheditor-1.2.1/xheditor_lang/zh-cn.js"></script>
<script language="javascript" src="__STATIC__/xheditor-1.2.1/editor_function.js"></script>
<script type="text/javascript">
	$(function() {
		$("a.gettag").click(function(event) {
			event.preventDefault();
			var type = $(this).attr('rel');
			$('#st_ajax_loading').show();
			$("#gettags .container_clicktags").load( SITEURL + 'index.php?option=misc&task=gettags&action='+type, {content:getContentFromEditor(),title:$("#title").val()}, function(){
				registerClickTags();
			});
			return false;
		});
		initEditor('jycms-ttHtmlEditor');
		if($('input[id="title"]')) {
			$('input[id="title"]')[0].focus();
		}
	});

	function showdivcustomfieldtext() {
		id = $("#customfieldid").val();
		for(i=1;i<=$tbodynum;i++){
			obj=$("#cf_"+i);
			if(i == id) {
				obj.show();
			} else {
				obj.hide();
			}
		}
	}
	function adddivcustomfield(id, str) {
		var oDiv=document.createElement("div");
		document.getElementById(id).appendChild(oDiv);
		oDiv.innerHTML = str;
	}
</script>
</block>